const { AsyncParallelHook } = require('tapable')

const hook = new AsyncParallelHook(['name', 'age'])

console.time('time')
hook.tapAsync('fn1', (name, age, callback) => {
  setTimeout(() => {
    console.log(`fn1 => ${name}: ${age}`)
    callback()
  }, 1000)
})

hook.tapAsync('fn2', (name, age, callback) => {
  setTimeout(() => {
    console.log(`fn2 => ${name}: ${age}`)
    callback('err')
  }, 2000)
})

hook.tapAsync('fn3', (name, age, callback) => {
  setTimeout(() => {
    console.log(`fn3 => ${name}: ${age}`)
    callback()
  }, 3000)
})

hook.callAsync('yhzzy', 18, function () {
  console.timeEnd('time')
})
